package com.example.monotarr;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
 
public class ListSQLiteHelper extends SQLiteOpenHelper {
  
    public ListSQLiteHelper(Context context, String nom, CursorFactory factory, int version) {
        super(context, nom, factory, version);
    } 
 
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE List (id INTEGER PRIMARY KEY ASC, titol TEXT, notes TEXT, " +
        		"prioritat INTEGER, dia INTEGER, mes INTEGER, any INTEGER, hora INTEGER, minut INTEGER, marcat INTEGER)");
        db.execSQL("CREATE TABLE LastID (lastid INTEGER)");
        db.execSQL("INSERT INTO LastID (lastid) VALUES (0)");
        db.execSQL("CREATE TABLE Ordre (ordre TEXT)");
        db.execSQL("INSERT INTO Ordre (ordre) VALUES ('id')");
        db.execSQL("CREATE TABLE Mida (mida INTEGER)");
        db.execSQL("INSERT INTO Mida (mida) VALUES (20)");
        db.execSQL("CREATE TABLE Fet (fet TEXT)");
        db.execSQL("INSERT INTO Fet (fet) VALUES ('tot')");
    }
 
    @Override
    public void onUpgrade(SQLiteDatabase db, int versionAnterior, int versionNueva) {
        db.execSQL("DROP TABLE IF EXISTS List");
        db.execSQL("DROP TABLE IF EXISTS LastID");
        db.execSQL("DROP TABLE IF EXISTS Ordre");
        db.execSQL("DROP TABLE IF EXISTS Mida");  
        db.execSQL("DROP TABLE IF EXISTS Fet");         
        db.execSQL("CREATE TABLE List (id INTEGER PRIMARY KEY ASC, titol TEXT, notes TEXT, " +
        		"prioritat INTEGER, dia INTEGER, mes INTEGER, any INTEGER, hora INTEGER, minut INTEGER, marcat INTEGER)");
        db.execSQL("CREATE TABLE LastID (lastid INTEGER)");
        db.execSQL("INSERT INTO LastID (lastid) VALUES (0)");
        db.execSQL("CREATE TABLE Ordre (ordre TEXT)");
        db.execSQL("INSERT INTO Ordre (ordre) VALUES ('id')");
        db.execSQL("CREATE TABLE Mida (mida INTEGER)");
        db.execSQL("INSERT INTO Mida (mida) VALUES (30)");
        db.execSQL("CREATE TABLE Fet (fet TEXT)");
        db.execSQL("INSERT INTO Fet (fet) VALUES ('tot')");
    }
}